#ifndef MAGICITEM_H_INCLUDED
#define MAGICITEM_H_INCLUDED

#include <allegro.h>
#include <list>
using std::list;

struct MoveInfo {
        short m_x;
        short m_y;
        short m_sx;
        short m_sy;
        MoveInfo() : m_x(0), m_y(0), m_sx(0), m_sy(0) {}
        MoveInfo(short x, short y) : m_x(x), m_y(y), m_sx(0), m_sy(0) {}
        MoveInfo(short x, short y, short sx, short sy) : m_x(x), m_y(y), m_sx(sx), m_sy(sy) {}

        void setPos(short x, short y) {
                m_x = x, m_y = y;
        }
        void setSpeed(short sx, short sy) {
                m_sx = sx, m_sy = sy;
        }
        void move() {
                m_x += m_sx;
                m_y += m_sy;
        }
};

class MagicItemBase
{
public:
        MagicItemBase() : m_valid(true) {}
        virtual ~MagicItemBase() {}
        virtual void OnTimer(int tick) = 0;
        virtual const char *name() const = 0;
        virtual int     getDamage() const = 0;
        virtual void OnDraw(BITMAP *surface) = 0;

        inline void setValid(bool flag) {
                m_valid = flag;
        }
        inline bool isValid() const {
                return m_valid;
        }
        inline bool isInvalid() const {
                return !m_valid;
        }

private:
        bool m_valid;
};

class MagicItemHandler
{
public:
        typedef MagicItemHandler class_type;
        typedef list<MagicItemBase *> MAGIC_ITEM_LIST;

        void addMagicItem(MagicItemBase *mit);
//    void removeMagicItem(MagicItemBase *mit);
        void OnTimer(int tick);
        void Draw(BITMAP *surface);
        inline size_t size() const {
                return m_magicItems.size();
        }
        ~MagicItemHandler();

private:
        MAGIC_ITEM_LIST m_magicItems;
};

/*
class FireBolt : public MagicItemBase
{
public:
        typedef FireBolt      class_type;
        typedef MagicItemBase parent_type;

        FireBolt(int lifetime, int damage, int id, int offset);
        ~FireBolt();
        virtual const char *name() const {
                return "FireBolt";
        }
        virtual int     getDamage() const {
                return m_damage;
        }
        virtual void    OnTimer(int tick);
        virtual void OnDraw(BITMAP *surface);

        void setPos(short x, short y) {
                m_mv.setPos(x, y);
        }
        void setSpeed(short sx, short sy) {
                m_mv.setSpeed(sx, sy);
        }

private:
        ushort m_monsterid;
        ushort m_monsteroffset;
        int m_lifetime;
        int m_damage;
        int m_frame;
        int m_lastMoveTime;

        BITMAP *m_tile;

        MoveInfo m_mv;
};
*/
#endif // MAGICITEM_H_INCLUDED
